package com.ateam.biz.impl;

import java.util.List;

import com.ateam.biz.ProjectsBiz;
import com.ateam.dao.ProjectsDao;
import com.ateam.pojo.Projects;

/** 
* @author WuYuan
* 
*/
public class ProjectsBizImpl implements ProjectsBiz {
	private ProjectsDao projectsDao;
	
	public ProjectsDao getProjectsDao() {
		return projectsDao;
	}

	public void setProjectsDao(ProjectsDao projectsDao) {
		this.projectsDao = projectsDao;
	}

	@Override
	public int addProject(Projects project,int userid) {
		try {
			projectsDao.addProject(project);
			return projectsDao.addProjectLeader(userid, project.getProjectid());
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return 0;
	}

	@Override
	public List<Projects> getProjectsByUser(int userid) {
		try {
			return projectsDao.getProjectsByUser(userid);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public Projects getProjectDetail(int projectid) {
		try {
			return projectsDao.getProjectByProjectid(projectid);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public int updateProjectComplete(int projectid) {
		try {
			return projectsDao.updateProjectComplete(projectid);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return 0;
	}

}
